<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>天下行租车</title>
    <script src="http://47.106.66.89:8080/js/vue.min.js"></script>
    <script src="http://47.106.66.89:8080/js/axios.min.js"></script>
    <link  href="http://47.106.66.89:8080/js/ele-2.15.7/theme-chalk/index.css" rel="stylesheet">
    <script src="http://47.106.66.89:8080/js/ele-2.15.7/index.js"></script>
    <script src="js/txx.js"></script>
    <script src="js/login.js"></script>
    <link rel="stylesheet" href="css/base.css">
</head>
<body>
<div id="app">
    <txx></txx>
        <main class="c900 el-card" style="align-items: stretch; width: 300px; padding: 0px 20px;">
            <h2>用户登录</h2>
            <el-form label-width="50px" label-position="left">
                <el-form-item label="账号: ">
                    <el-input placeholder="账号" v-model="username"></el-input>
                </el-form-item>
                <el-form-item label="密码: ">
                    <el-input type="password" placeholder="密码" v-model="password"></el-input>
                </el-form-item>
                <el-form-item style="text-align: right">
                    <el-link :underline="false" @click="dialogFormVisible = true">忘记密码</el-link>
                    <el-button type="primary" @click="login">登录</el-button>
                </el-form-item>
            </el-form>

            <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
                <el-form>
                    <el-form-item label="账号" :label-width="formLabelWidth">
                        <el-input v-model="username" autocomplete="off"></el-input>
                    </el-form-item>

                    <el-form-item label="邮箱" :label-width="formLabelWidth">
                        <el-input v-model="email" autocomplete="off" style="width: 70%"></el-input>
                        <el-button type="primary" @click="send">发送验证码</el-button>
                    </el-form-item>

                    <el-form-item label="验证码" :label-width="formLabelWidth">
                        <el-input v-model="vcode" autocomplete="off"></el-input>
                    </el-form-item>

                    <el-form-item label="新密码" :label-width="formLabelWidth">
                        <el-input v-model="password" autocomplete="off"></el-input>
                    </el-form-item>

                    <el-form-item label="确认密码" :label-width="formLabelWidth">
                        <el-input v-model="reUpass" autocomplete="off"></el-input>
                    </el-form-item>

                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible = false">取 消</el-button>
                    <el-button type="primary" @click="dialogFormVisible = false">修改</el-button>
                </div>
            </el-dialog>
        </main>

</div>
<script>
    var v = new Vue({
        el : "#app",
        data:{
                username:"",
                password:"",
                reUpass:"",
                vcode:"",
                email:"",
            dialogFormVisible:false,
            formLabelWidth: '120px',
        },
        created(){

        },
        methods:{
            login(){
                axios.get("login/login", {
                    params: {
                        username:this.username,
                        password:this.password,
                    }
                }).then(res=>{
                    if (res.data.code == 1) {
                        this.$message(res.data.msg)
                        if(res.data.data.goto){
                            location.href = res.data.data.goto
                        }else if(sessionStorage.getItem("goto")){
                            location.href = sessionStorage.getItem("goto")
                        }else{
                            location.href = "index.html"
                        }
                    }else{
                        this.$alert(res.data.msg)
                    }
                })
            },
            send(){
                let p = new URLSearchParams();
                p.append("username", this.username);
                p.append("email", this.email);
                axios.post("login/forgetPwd", p).then(res=>{
                    if (res.data.code == 1) {
                        this.$message(res.data.msg)
                    }else{
                        this.$alert(res.data.msg)
                    }
                })
            }
        }
    })
</script>
</body>
</html>
